﻿using System;
using System.IO;
using System.Net;

namespace HVACWebService.Common
{
    /// <summary>
    /// Tools 的摘要说明
    /// </summary>
    public class HttpRequestTools
    {

        public  string GetHttpRequest(string theUrl)
        {
            try
            {
                Uri uri = new Uri(theUrl);
                HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uri);
                request.Method = "Get";
                request.ContentType = "application/x-www-form-urlencoded";
                request.AllowAutoRedirect = false;
                request.Timeout = 5000;
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                Stream responseStream = response.GetResponseStream();
                StreamReader readStream = new StreamReader(responseStream, System.Text.Encoding.UTF8);
                string retext = readStream.ReadToEnd();
                readStream.Close();
                return retext;
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
        }

    }
}